import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
// 创建store仓库
const store =new Vuex.Store({
  state:{
    count:10
  },
  mutations:{
    increment(state, step){
      state.count-=step;
    }
  },
  actions:{
    increment(context, step){
      context.commit('increment', step);
    }
  },
  getters:{
    getCount(state){
      return state.count>=0 ? state.count:0;
    }
  }
});

export default store;
